package com.ruoyi.web.controller.system;

import java.util.List;
import javax.servlet.http.HttpServletResponse;

import com.ruoyi.system.domain.BanknoteSerialNumberRecord;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.system.domain.BanknoteSerialNumberPairing;
import com.ruoyi.system.service.IBanknoteSerialNumberPairingService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 冠字号配对Controller
 * 
 * @author ruoyi
 * @date 2025-02-27
 */
@RestController
@RequestMapping("/system/pairing")
public class BanknoteSerialNumberPairingController extends BaseController
{
    @Autowired
    private IBanknoteSerialNumberPairingService banknoteSerialNumberPairingService;

    /**
     * 查询冠字号配对列表
     */
    @PreAuthorize("@ss.hasPermi('system:pairing:list')")
    @GetMapping("/list")
    public TableDataInfo list(BanknoteSerialNumberPairing banknoteSerialNumberPairing)
    {
        List<BanknoteSerialNumberRecord> list = banknoteSerialNumberPairingService.selectBanknoteSerialNumberPairingList(banknoteSerialNumberPairing);
        return getDataTable(list);
    }

    /**
     * 导出冠字号配对列表
     */
    @PreAuthorize("@ss.hasPermi('system:pairing:export')")
    @Log(title = "冠字号配对", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, BanknoteSerialNumberPairing banknoteSerialNumberPairing)
    {
        List<BanknoteSerialNumberRecord> list = banknoteSerialNumberPairingService.selectBanknoteSerialNumberPairingList(banknoteSerialNumberPairing);
        ExcelUtil<BanknoteSerialNumberRecord> util = new ExcelUtil<BanknoteSerialNumberRecord>(BanknoteSerialNumberRecord.class);
        util.exportExcel(response, list, "冠字号配对数据");
    }

    /**
     * 获取冠字号配对详细信息
     */
    @PreAuthorize("@ss.hasPermi('system:pairing:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(banknoteSerialNumberPairingService.selectBanknoteSerialNumberPairingById(id));
    }

    /**
     * 新增冠字号配对
     */
    @PreAuthorize("@ss.hasPermi('system:pairing:add')")
    @Log(title = "冠字号配对", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody BanknoteSerialNumberPairing banknoteSerialNumberPairing)
    {
        return toAjax(banknoteSerialNumberPairingService.insertBanknoteSerialNumberPairing(banknoteSerialNumberPairing));
    }

    /**
     * 修改冠字号配对
     */
    @PreAuthorize("@ss.hasPermi('system:pairing:edit')")
    @Log(title = "冠字号配对", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody BanknoteSerialNumberPairing banknoteSerialNumberPairing)
    {
        return toAjax(banknoteSerialNumberPairingService.updateBanknoteSerialNumberPairing(banknoteSerialNumberPairing));
    }

    /**
     * 删除冠字号配对
     */
    @PreAuthorize("@ss.hasPermi('system:pairing:remove')")
    @Log(title = "冠字号配对", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(banknoteSerialNumberPairingService.deleteBanknoteSerialNumberPairingByIds(ids));
    }
}
